//
//  JYUnityMacHelper.m
//  JYMacSDK
//
 //  Created by zlongame on 2021/8/23.
 //

 #import "JYUnityMacHelper.h"

 extern "C"{
     extern NSString* CreateNsstring (const char* string);
     Unity_Callback1 sCallback = NULL;
 }

 @implementation JYUnityMacHelper

 +(void)JYFunc2:(NSString *)someThing
 {
     if (sCallback) {
         sCallback(strdup([@"MacSDKFunc2" UTF8String]),strdup([someThing UTF8String]));
     }
 }

 @end

 extern "C" NSString* CreateNsstring (const char* string)
 {
     if (string)
         return [NSString stringWithUTF8String: string];
     else
         return [NSString stringWithUTF8String: ""];
 }

 ///定义接收Unity回调的方法
 extern "C" void _MacSDKSetCallBack(Unity_Callback1 callbackFunc)
 {
     sCallback = callbackFunc;
 }

 ///也可以定义函数的参数作类型的
 extern "C" void _MacSDKFunc1(const char * someThing,Unity_Callback1 callbackFunc)
 {
     ///在函数参数回调
     callbackFunc(strdup([@"MacSDKFunc1" UTF8String]),strdup(someThing));
 }

 ///使用全局函数返回内容
 extern "C" void _MacSDKFunc2(const char * someThing)
 {
     [JYUnityMacHelper JYFunc2:CreateNsstring(someThing)];
 }

